package com.midian.common.utils;

import java.util.Random;

public class ActivationCodeValue {

	private Random random;
	private String table;
	
	public ActivationCodeValue(){
		random = new Random();
		table = "0123456789";
	}
	
	public String getActivationCodeValue(long id){
		
		String ret = null,num = String.format("%05d", id);
		int key = random.nextInt(10),seed = random.nextInt(100);
		Caesar caesar = new Caesar(table, seed);
		num = caesar.encode(key, num);
		ret = num + String.format("%01d", key)
	    + String.format("%02d", seed);
		return ret;
	}
//	public static void main(String[] args) {
//		ActivationCodeValue acv=new ActivationCodeValue();
//		System.out.println(acv.getActivationCodeValue(355443655));
//		System.out.println(acv.getActivationCodeValue(355443655));
//	}
}
